package com.geekstudy.week9.controller;

import com.geekstudy.core.api.RpcfxResolver;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class DemoResolver implements RpcfxResolver, ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Override
    public Object resolve(String serviceClass) {
        return this.applicationContext.getBean(serviceClass);
    }

    /**
     *
     * 泛型 获取实现类
     * @param tClass
     * @param <T>
     * @return
     */
    @Override
    public <T> T resolve(Class tClass) {
        return (T)this.applicationContext.getBean(tClass);
    }


}
